import { getUserInfoApi } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            headImg: require("@/assets/img/service.848ec511.png"),
            nickName: '游客',
            coin: 0
        },
        cartTotal: 0,
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state) {
            state.userInfo = {
                headImg: require("@/assets/img/userImg.f8bbec5e.png"),
                nickName: "--",
                coin: "--"
            }
        }
    },
    actions: {
        async asyncChangeUserInfo({ commit }) {
            let getUserInfo = await getUserInfoApi()
            console.log({ getUserInfo });
            commit("changeUserInfo", getUserInfo.data)
        }
    }
}